package com.wsx.ones.monitor.core.util;

import com.wsx.ones.monitor.common.Common;
import org.apache.commons.lang3.StringUtils;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * 日期工具类
 * Created by wangshuaixin on 17/3/21.
 */
public class DateUtil {

    //获得当前系统指定毫秒值
    public static Long getCurrentTimes() {
        return System.currentTimeMillis();
    }

    //获得当前时间值
    public static Date getCurrentDate() {
        return new Date();
    }

    //获得当前的时间字符串
    public static String getCurrentStrDate(String format) {
        if (StringUtils.isEmpty(format)) {
            format = Common.DATE_NORMAL_FORMAT;
        }
        SimpleDateFormat dateFormat = new SimpleDateFormat(format);
        return dateFormat.format(getCurrentDate());
    }
}
